package com.heima.feign.article;

import com.heima.feign.article.fallback.IArticleClientFallback;
import com.heima.model.article.dtos.ArticleCommentDto;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.comment.dtos.ApCommentDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.StatisticsDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

//指定fegin降级后访问哪个类：IArticleClientFallback.class
@FeignClient(value = "leadnews-article",fallback = IArticleClientFallback.class)//暴露接口
public interface IArtileFeignClient {
    @PostMapping("/api/v1/article/save")
    public ResponseResult saveArticle(@RequestBody ArticleDto articleDto);

    @GetMapping("/api/v1/article/queryLikesAndConllections")
    ResponseResult queryLikesAndConllections(@RequestParam("wmUserId") Integer wmUserId, @RequestParam("beginDate") Date beginDate, @RequestParam("endDate") Date endDate);

    @PostMapping("/api/v1/article/newPage")
    PageResponseResult newPage(@RequestBody StatisticsDto dto);


    @PostMapping("/api/v1/article/findNewsComments")
    public PageResponseResult findNewsComments(@RequestBody ArticleCommentDto dto);

    /**
     * 文章评论开启或关闭状态
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/article/isChannel")
    public ResponseResult isChannel(@RequestBody ApCommentDto dto);

    /**
     * 删除评论数,点赞数
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/article/delChannel")
    public ResponseResult delChannelState(@RequestBody ApCommentDto dto);

    @GetMapping("/api/v1/article/findArticleConfigByArticleId/{articleID}")
    public ResponseResult findArticleConfigaByArticleId(@PathVariable("articleID") Long id);

    /**
     * 保存文章评论数
     * @param entryId
     */
    @GetMapping("/api/v1/article/update/{entryId}")
    ResponseResult updateComment(@PathVariable("entryId") Long entryId);

    /**
     * 判断该文章是否开启评论
     * @param entryId
     * @return
     */
    @GetMapping("/api/v1/article/state/{entryId}")
    ResponseResult stateComment(@PathVariable("entryId")Long entryId);
}
